package br.unb.mestrado.simulator.model.sm;

import br.unb.mestrado.simulator.model.spl.Feature;
import br.unb.mestrado.simulator.sm.SystemState;

public class DomainMachine {

	private SystemState currentState = SystemState.HIGH_RISK;
	private SystemState[][] matrix = null;
	private float[] goals = null;
	private String name = null;
	private Feature feature;
	
	public DomainMachine(String name) {
		this.name  = name;
		matrix = new SystemState[3][3];
		goals = new float[3];
	}
	
	public void addConnection(SystemState from, SystemState to, SystemState value){
		this.matrix[from.getIndex()]		[to.getIndex()	] = value;
	}

	public SystemState get(SystemState from, SystemState to) {
		return this.matrix[from.getIndex()][to.getIndex()];
	}

	public void setQoSGoal(SystemState state, float f) {
		goals[state.getIndex()] = f;
	}

	public SystemState getCurrentState() {
		return currentState;
	}

	public void changeState(SystemState eventSystem) {
		this.currentState = matrix[this.currentState.getIndex()][eventSystem.getIndex()];
	}
	
	public Float getQoSGoal(SystemState newState) {
		return this.goals[newState.getIndex()];
	}
	
	public void onDestroy() {
		// TODO Auto-generated method stub
		
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Feature getFeature() {
		return feature;
	}

	public void setFeature(Feature feature) {
		this.feature = feature;
	}
	
}
